package Code;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import DatabaseCommands.DatabaseInfo;
import Panels.DatabaseHome;


public class RunQuery{
	
	DatabaseInfo DInfo=DatabaseInfo.getInstance();
	DatabaseHome DBHome=DatabaseHome.getInstance();
	private TablePanelInfo TPInfo;
	
	public RunQuery(TablePanelInfo TPInfo){
		TPInfo=this.TPInfo;
		List<String> Lines=new ArrayList<String>(Arrays.asList(TPInfo.GetTextArea().getText().split("\\n")));
		System.out.println();
		for(String Item:Lines){
			if(Item.compareTo("\n")==0){continue;}
			try{
				DInfo.GetConnection().createStatement().execute(Item);
			}catch(Exception e){
				System.out.println(e.getMessage());
			}
		}
		DBHome.UpdateTableTreeView();
		
	}
	
	
}
